﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using Olympic_email_to_future.Module;

namespace FutureMeWeb
{
    public partial class login : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {

            AccountBtn.Visible = false;
            LogoffBtn.Visible = false;
        }

        public Olympic_email_to_future.IBLL.IUserBLL bll = Olympic_email_to_future.BLLFactory.BusinessFactory.CreateUserBLL();

        protected void Button1_Click(object sender, EventArgs e)
        {
            UserInfo user = new UserInfo();
            user.userMailAddress = TextBox1.Text;
            user.userPassword = TextBox2.Text;
            if (bll.login(user)) 
            {
                Session.Add("User", bll.getUser(user));
                Response.Write("<script>alert('登陆成功')</script>");
                Response.Redirect("index.aspx");
            }
            else
                Response.Write("<script>alert('用户名或密码错误，请重新输入')</script>");
        }

        protected void Button2_Click(object sender, EventArgs e)
        {
            TextBox1.Text = "";
            TextBox2.Text = "";
        }
    }
}